﻿using System;
using Microsoft.SharePoint.Administration;

namespace Hvam.SharePoint.Search
{
    internal class Logger
    {
        private static Logger Instance { get; set; }

        public SPDiagnosticsCategory Category { get; set; }

        private Logger()
        {
            Category = SPDiagnosticsService.Local.Areas["SharePoint Foundation Search"].Categories["Query"];
        }

        public void Trace(Exception exception)
        {
            SPDiagnosticsService.Local.WriteTrace(0, Category, TraceSeverity.Medium, exception.ToString());
        }

        public static Logger Current
        {
            get
            {
                return Instance ?? (Instance = new Logger());
            }
        }
    }
}
